package com.InterfaceIsolation;

import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * 方案二：
 * 细化接口，根据条件进行实现
 */
public class Solation2 {

    public static void main(String[] args) {
        CC cc=new CC();
        //CC类通过接口去依赖AA类中得方法。父类引用指向子类对象
        cc.dependcies1(new AA());
        cc.dependcies2(new AA());
        cc.dependcies3(new AA());
        DD dd=new DD();
        dd.dependcies4(new BB());
        dd.dependcies4(new BB());

    }
}


interface Interfa1{
    public void operation1();
}

interface Interfa2{
    public void operation2();
    public void operation3();
}

interface Interfa3{
    public void operation4();
    public void operation5();
}

class AA implements Interfa1,Interfa2{

    public void operation1() {
        System.out.println("AA 实现了Interfa1,Interfa2 重写了operation1()");
    }

    public void operation2() {
        System.out.println("AA 实现了Interfa1,Interfa2 重写了operation2()");
    }

    public void operation3() {
        System.out.println("AA 实现了Interfa1,Interfa2 重写了operation3()");
    }
}

class BB implements Interfa3{

    public void operation4() {
        System.out.println("BB 实现了Interfa3 重写了operation4()");
    }

    public void operation5() {
        System.out.println("BB 实现了Interfa3 重写了operation5()");
    }
}

class CC{
    public void dependcies1(Interfa1 i){
        i.operation1();
    }

    public void dependcies2(Interfa2 i){
        i.operation2();
    }

    public void dependcies3(Interfa2 i){
        i.operation3();
    }
}

class DD{
    public void dependcies4(Interfa3 i){
        i.operation4();
    }

    public void dependcies5(Interfa3 i){
        i.operation5();
    }
}